<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP, NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# OPTIONS_GHC -funbox-strict-fields #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Module      :  GHC.IO.Encoding</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 2008-2009</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Text codecs for I/O</span><span>
</span><span id="line-16"></span><span class="hs-comment">--</span><span>
</span><span id="line-17"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.Encoding</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#BufferCodec"><span class="hs-identifier">BufferCodec</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier">TextEncoding</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoder"><span class="hs-identifier">TextEncoder</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextDecoder"><span class="hs-identifier">TextDecoder</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#CodingProgress"><span class="hs-identifier">CodingProgress</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#latin1"><span class="hs-identifier">latin1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#latin1_encode"><span class="hs-identifier">latin1_encode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#latin1_decode"><span class="hs-identifier">latin1_decode</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#utf8"><span class="hs-identifier">utf8</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#utf8_bom"><span class="hs-identifier">utf8_bom</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#utf16"><span class="hs-identifier">utf16</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#utf16le"><span class="hs-identifier">utf16le</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#utf16be"><span class="hs-identifier">utf16be</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#utf32"><span class="hs-identifier">utf32</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#utf32le"><span class="hs-identifier">utf32le</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#utf32be"><span class="hs-identifier">utf32be</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#initLocaleEncoding"><span class="hs-identifier">initLocaleEncoding</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#getLocaleEncoding"><span class="hs-identifier">getLocaleEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#getFileSystemEncoding"><span class="hs-identifier">getFileSystemEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#getForeignEncoding"><span class="hs-identifier">getForeignEncoding</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#setLocaleEncoding"><span class="hs-identifier">setLocaleEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#setFileSystemEncoding"><span class="hs-identifier">setFileSystemEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#setForeignEncoding"><span class="hs-identifier">setForeignEncoding</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#char8"><span class="hs-identifier">char8</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#mkTextEncoding"><span class="hs-identifier">mkTextEncoding</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>        </span><span class="annot"><a href="GHC.IO.Encoding.html#argvEncoding"><span class="hs-identifier">argvEncoding</span></a></span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Exception.html"><span class="hs-identifier">GHC.IO.Exception</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html"><span class="hs-identifier">GHC.IO.Buffer</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html"><span class="hs-identifier">GHC.IO.Encoding.Failure</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html"><span class="hs-identifier">GHC.IO.Encoding.Types</span></a></span><span class="hs-cpp">
#if !defined(mingw32_HOST_OS)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="hs-identifier">GHC.IO.Encoding.Iconv</span><span> </span><span class="hs-keyword">as</span><span> </span><span class="hs-identifier">Iconv</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.CodePage.html"><span class="hs-identifier">GHC.IO.Encoding.CodePage</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">CodePage</span></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Text.Read.html"><span class="hs-identifier">Text.Read</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Read.html#reads"><span class="hs-identifier">reads</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Latin1.html"><span class="hs-identifier">GHC.IO.Encoding.Latin1</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Latin1</span></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.UTF8.html"><span class="hs-identifier">GHC.IO.Encoding.UTF8</span></a></span><span>   </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">UTF8</span></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.UTF16.html"><span class="hs-identifier">GHC.IO.Encoding.UTF16</span></a></span><span>  </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">UTF16</span></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.UTF32.html"><span class="hs-identifier">GHC.IO.Encoding.UTF32</span></a></span><span>  </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">UTF32</span></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.List.html"><span class="hs-identifier">GHC.List</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Word.html"><span class="hs-identifier">GHC.Word</span></a></span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.IORef.html"><span class="hs-identifier">Data.IORef</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Char.html"><span class="hs-identifier">Data.Char</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Unicode.html#toUpper"><span class="hs-identifier">toUpper</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.IO.Unsafe.html"><span class="hs-identifier">System.IO.Unsafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Unsafe.html#unsafePerformIO"><span class="hs-identifier">unsafePerformIO</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span class="hs-comment">-- | The Latin1 (ISO8859-1) encoding.  This encoding maps bytes</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- directly to the first 256 Unicode code points, and is thus not a</span><span>
</span><span id="line-59"></span><span class="hs-comment">-- complete Unicode encoding.  An attempt to write a character greater than</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- @\'\\255\'@ to a 'System.IO.Handle' using the 'latin1' encoding will result in an</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- error.</span><span>
</span><span id="line-62"></span><span class="annot"><a href="GHC.IO.Encoding.html#latin1"><span class="hs-identifier hs-type">latin1</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-63"></span><span id="latin1"><span class="annot"><span class="annottext">latin1 :: TextEncoding
</span><a href="GHC.IO.Encoding.html#latin1"><span class="hs-identifier hs-var hs-var">latin1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.Latin1.html#latin1_checked"><span class="hs-identifier hs-var">Latin1.latin1_checked</span></a></span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-comment">-- | The UTF-8 Unicode encoding</span><span>
</span><span id="line-66"></span><span class="annot"><a href="GHC.IO.Encoding.html#utf8"><span class="hs-identifier hs-type">utf8</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-67"></span><span id="utf8"><span class="annot"><span class="annottext">utf8 :: TextEncoding
</span><a href="GHC.IO.Encoding.html#utf8"><span class="hs-identifier hs-var hs-var">utf8</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.UTF8.html#utf8"><span class="hs-identifier hs-var">UTF8.utf8</span></a></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-comment">-- | The UTF-8 Unicode encoding, with a byte-order-mark (BOM; the byte</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- sequence 0xEF 0xBB 0xBF).  This encoding behaves like 'utf8',</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- except that on input, the BOM sequence is ignored at the beginning</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- of the stream, and on output, the BOM sequence is prepended.</span><span>
</span><span id="line-73"></span><span class="hs-comment">--</span><span>
</span><span id="line-74"></span><span class="hs-comment">-- The byte-order-mark is strictly unnecessary in UTF-8, but is</span><span>
</span><span id="line-75"></span><span class="hs-comment">-- sometimes used to identify the encoding of a file.</span><span>
</span><span id="line-76"></span><span class="hs-comment">--</span><span>
</span><span id="line-77"></span><span class="annot"><a href="GHC.IO.Encoding.html#utf8_bom"><span class="hs-identifier hs-type">utf8_bom</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-78"></span><span id="utf8_bom"><span class="annot"><span class="annottext">utf8_bom :: TextEncoding
</span><a href="GHC.IO.Encoding.html#utf8_bom"><span class="hs-identifier hs-var hs-var">utf8_bom</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.UTF8.html#utf8_bom"><span class="hs-identifier hs-var">UTF8.utf8_bom</span></a></span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-comment">-- | The UTF-16 Unicode encoding (a byte-order-mark should be used to</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- indicate endianness).</span><span>
</span><span id="line-82"></span><span class="annot"><a href="GHC.IO.Encoding.html#utf16"><span class="hs-identifier hs-type">utf16</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-83"></span><span id="utf16"><span class="annot"><span class="annottext">utf16 :: TextEncoding
</span><a href="GHC.IO.Encoding.html#utf16"><span class="hs-identifier hs-var hs-var">utf16</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.UTF16.html#utf16"><span class="hs-identifier hs-var">UTF16.utf16</span></a></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="hs-comment">-- | The UTF-16 Unicode encoding (little-endian)</span><span>
</span><span id="line-86"></span><span class="annot"><a href="GHC.IO.Encoding.html#utf16le"><span class="hs-identifier hs-type">utf16le</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-87"></span><span id="utf16le"><span class="annot"><span class="annottext">utf16le :: TextEncoding
</span><a href="GHC.IO.Encoding.html#utf16le"><span class="hs-identifier hs-var hs-var">utf16le</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.UTF16.html#utf16le"><span class="hs-identifier hs-var">UTF16.utf16le</span></a></span><span>
</span><span id="line-88"></span><span>
</span><span id="line-89"></span><span class="hs-comment">-- | The UTF-16 Unicode encoding (big-endian)</span><span>
</span><span id="line-90"></span><span class="annot"><a href="GHC.IO.Encoding.html#utf16be"><span class="hs-identifier hs-type">utf16be</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-91"></span><span id="utf16be"><span class="annot"><span class="annottext">utf16be :: TextEncoding
</span><a href="GHC.IO.Encoding.html#utf16be"><span class="hs-identifier hs-var hs-var">utf16be</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.UTF16.html#utf16be"><span class="hs-identifier hs-var">UTF16.utf16be</span></a></span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-comment">-- | The UTF-32 Unicode encoding (a byte-order-mark should be used to</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- indicate endianness).</span><span>
</span><span id="line-95"></span><span class="annot"><a href="GHC.IO.Encoding.html#utf32"><span class="hs-identifier hs-type">utf32</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-96"></span><span id="utf32"><span class="annot"><span class="annottext">utf32 :: TextEncoding
</span><a href="GHC.IO.Encoding.html#utf32"><span class="hs-identifier hs-var hs-var">utf32</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.UTF32.html#utf32"><span class="hs-identifier hs-var">UTF32.utf32</span></a></span><span>
</span><span id="line-97"></span><span>
</span><span id="line-98"></span><span class="hs-comment">-- | The UTF-32 Unicode encoding (little-endian)</span><span>
</span><span id="line-99"></span><span class="annot"><a href="GHC.IO.Encoding.html#utf32le"><span class="hs-identifier hs-type">utf32le</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-100"></span><span id="utf32le"><span class="annot"><span class="annottext">utf32le :: TextEncoding
</span><a href="GHC.IO.Encoding.html#utf32le"><span class="hs-identifier hs-var hs-var">utf32le</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.UTF32.html#utf32le"><span class="hs-identifier hs-var">UTF32.utf32le</span></a></span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span class="hs-comment">-- | The UTF-32 Unicode encoding (big-endian)</span><span>
</span><span id="line-103"></span><span class="annot"><a href="GHC.IO.Encoding.html#utf32be"><span class="hs-identifier hs-type">utf32be</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-104"></span><span id="utf32be"><span class="annot"><span class="annottext">utf32be :: TextEncoding
</span><a href="GHC.IO.Encoding.html#utf32be"><span class="hs-identifier hs-var hs-var">utf32be</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.UTF32.html#utf32be"><span class="hs-identifier hs-var">UTF32.utf32be</span></a></span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span class="hs-comment">-- | The Unicode encoding of the current locale</span><span>
</span><span id="line-107"></span><span class="hs-comment">--</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- @since 4.5.0.0</span><span>
</span><span id="line-109"></span><span class="annot"><a href="GHC.IO.Encoding.html#getLocaleEncoding"><span class="hs-identifier hs-type">getLocaleEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-110"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#getLocaleEncoding"><span class="hs-pragma hs-type">getLocaleEncoding</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-comment">-- | The Unicode encoding of the current locale, but allowing arbitrary</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- undecodable bytes to be round-tripped through it.</span><span>
</span><span id="line-114"></span><span class="hs-comment">--</span><span>
</span><span id="line-115"></span><span class="hs-comment">-- This 'TextEncoding' is used to decode and encode command line arguments</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- and environment variables on non-Windows platforms.</span><span>
</span><span id="line-117"></span><span class="hs-comment">--</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- On Windows, this encoding *should not* be used if possible because</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- the use of code pages is deprecated: Strings should be retrieved</span><span>
</span><span id="line-120"></span><span class="hs-comment">-- via the &quot;wide&quot; W-family of UTF-16 APIs instead</span><span>
</span><span id="line-121"></span><span class="hs-comment">--</span><span>
</span><span id="line-122"></span><span class="hs-comment">-- @since 4.5.0.0</span><span>
</span><span id="line-123"></span><span class="annot"><a href="GHC.IO.Encoding.html#getFileSystemEncoding"><span class="hs-identifier hs-type">getFileSystemEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-124"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#getFileSystemEncoding"><span class="hs-pragma hs-type">getFileSystemEncoding</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span class="hs-comment">-- | The Unicode encoding of the current locale, but where undecodable</span><span>
</span><span id="line-127"></span><span class="hs-comment">-- bytes are replaced with their closest visual match. Used for</span><span>
</span><span id="line-128"></span><span class="hs-comment">-- the 'Foreign.C.String.CString' marshalling functions in &quot;Foreign.C.String&quot;</span><span>
</span><span id="line-129"></span><span class="hs-comment">--</span><span>
</span><span id="line-130"></span><span class="hs-comment">-- @since 4.5.0.0</span><span>
</span><span id="line-131"></span><span class="annot"><a href="GHC.IO.Encoding.html#getForeignEncoding"><span class="hs-identifier hs-type">getForeignEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-132"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#getForeignEncoding"><span class="hs-pragma hs-type">getForeignEncoding</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="hs-comment">-- | @since 4.5.0.0</span><span>
</span><span id="line-135"></span><span class="annot"><a href="GHC.IO.Encoding.html#setLocaleEncoding"><span class="hs-identifier hs-type">setLocaleEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#setFileSystemEncoding"><span class="hs-identifier hs-type">setFileSystemEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#setForeignEncoding"><span class="hs-identifier hs-type">setForeignEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-136"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#setLocaleEncoding"><span class="hs-pragma hs-type">setLocaleEncoding</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-137"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#setFileSystemEncoding"><span class="hs-pragma hs-type">setFileSystemEncoding</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-138"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#setForeignEncoding"><span class="hs-pragma hs-type">setForeignEncoding</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-139"></span><span>
</span><span id="line-140"></span><span class="hs-special">(</span><span id="getLocaleEncoding"><span class="annot"><span class="annottext">IO TextEncoding
</span><a href="GHC.IO.Encoding.html#getLocaleEncoding"><span class="hs-identifier hs-var">getLocaleEncoding</span></a></span></span><span class="hs-special">,</span><span> </span><span id="setLocaleEncoding"><span class="annot"><span class="annottext">TextEncoding -&gt; IO ()
</span><a href="GHC.IO.Encoding.html#setLocaleEncoding"><span class="hs-identifier hs-var">setLocaleEncoding</span></a></span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; (IO TextEncoding, TextEncoding -&gt; IO ())
forall a. a -&gt; (IO a, a -&gt; IO ())
</span><a href="GHC.IO.Encoding.html#mkGlobal"><span class="hs-identifier hs-var">mkGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.html#initLocaleEncoding"><span class="hs-identifier hs-var">initLocaleEncoding</span></a></span><span>
</span><span id="line-141"></span><span class="hs-special">(</span><span id="getFileSystemEncoding"><span class="annot"><span class="annottext">IO TextEncoding
</span><a href="GHC.IO.Encoding.html#getFileSystemEncoding"><span class="hs-identifier hs-var">getFileSystemEncoding</span></a></span></span><span class="hs-special">,</span><span> </span><span id="setFileSystemEncoding"><span class="annot"><span class="annottext">TextEncoding -&gt; IO ()
</span><a href="GHC.IO.Encoding.html#setFileSystemEncoding"><span class="hs-identifier hs-var">setFileSystemEncoding</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; (IO TextEncoding, TextEncoding -&gt; IO ())
forall a. a -&gt; (IO a, a -&gt; IO ())
</span><a href="GHC.IO.Encoding.html#mkGlobal"><span class="hs-identifier hs-var">mkGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.html#initFileSystemEncoding"><span class="hs-identifier hs-var">initFileSystemEncoding</span></a></span><span>
</span><span id="line-142"></span><span class="hs-special">(</span><span id="getForeignEncoding"><span class="annot"><span class="annottext">IO TextEncoding
</span><a href="GHC.IO.Encoding.html#getForeignEncoding"><span class="hs-identifier hs-var">getForeignEncoding</span></a></span></span><span class="hs-special">,</span><span> </span><span id="setForeignEncoding"><span class="annot"><span class="annottext">TextEncoding -&gt; IO ()
</span><a href="GHC.IO.Encoding.html#setForeignEncoding"><span class="hs-identifier hs-var">setForeignEncoding</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; (IO TextEncoding, TextEncoding -&gt; IO ())
forall a. a -&gt; (IO a, a -&gt; IO ())
</span><a href="GHC.IO.Encoding.html#mkGlobal"><span class="hs-identifier hs-var">mkGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.html#initForeignEncoding"><span class="hs-identifier hs-var">initForeignEncoding</span></a></span><span>
</span><span id="line-143"></span><span>
</span><span id="line-144"></span><span id="local-6989586621679530967"><span class="annot"><a href="GHC.IO.Encoding.html#mkGlobal"><span class="hs-identifier hs-type">mkGlobal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679530967"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679530967"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679530967"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
</span><span id="line-145"></span><span id="mkGlobal"><span class="annot"><span class="annottext">mkGlobal :: forall a. a -&gt; (IO a, a -&gt; IO ())
</span><a href="GHC.IO.Encoding.html#mkGlobal"><span class="hs-identifier hs-var hs-var">mkGlobal</span></a></span></span><span> </span><span id="local-6989586621679530871"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679530871"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (IO a, a -&gt; IO ()) -&gt; (IO a, a -&gt; IO ())
forall a. IO a -&gt; a
</span><a href="GHC.IO.Unsafe.html#unsafePerformIO"><span class="hs-identifier hs-var">unsafePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (IO a, a -&gt; IO ()) -&gt; (IO a, a -&gt; IO ()))
-&gt; IO (IO a, a -&gt; IO ()) -&gt; (IO a, a -&gt; IO ())
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-146"></span><span>    </span><span id="local-6989586621679530870"><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679530870"><span class="hs-identifier hs-var">x_ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO (IORef a)
forall a. a -&gt; IO (IORef a)
</span><a href="GHC.IORef.html#newIORef"><span class="hs-identifier hs-var">newIORef</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679530871"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-147"></span><span>    </span><span class="annot"><span class="annottext">(IO a, a -&gt; IO ()) -&gt; IO (IO a, a -&gt; IO ())
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IORef a -&gt; IO a
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679530870"><span class="hs-identifier hs-var">x_ref</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">IORef a -&gt; a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679530870"><span class="hs-identifier hs-var">x_ref</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#mkGlobal"><span class="hs-pragma hs-type">mkGlobal</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-149"></span><span>
</span><span id="line-150"></span><span class="hs-comment">-- | @since 4.5.0.0</span><span>
</span><span id="line-151"></span><span class="annot"><a href="GHC.IO.Encoding.html#initLocaleEncoding"><span class="hs-identifier hs-type">initLocaleEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#initFileSystemEncoding"><span class="hs-identifier hs-type">initFileSystemEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#initForeignEncoding"><span class="hs-identifier hs-type">initForeignEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-152"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html#initLocaleEncoding"><span class="hs-pragma hs-type">initLocaleEncoding</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-153"></span><span class="hs-comment">-- N.B. initLocaleEncoding is exported for use in System.IO.localeEncoding.</span><span>
</span><span id="line-154"></span><span class="hs-comment">-- NOINLINE ensures that this result is shared.</span><span class="hs-cpp">

#if !defined(mingw32_HOST_OS)
</span><span class="hs-comment">-- It is rather important that we don't just call Iconv.mkIconvEncoding here</span><span>
</span><span id="line-158"></span><span class="hs-comment">-- because some iconvs (in particular GNU iconv) will brokenly UTF-8 encode</span><span>
</span><span id="line-159"></span><span class="hs-comment">-- lone surrogates without complaint.</span><span>
</span><span id="line-160"></span><span class="hs-comment">--</span><span>
</span><span id="line-161"></span><span class="hs-comment">-- By going through our Haskell implementations of those encodings, we are</span><span>
</span><span id="line-162"></span><span class="hs-comment">-- guaranteed to catch such errors.</span><span>
</span><span id="line-163"></span><span class="hs-comment">--</span><span>
</span><span id="line-164"></span><span class="hs-comment">-- FIXME: this is not a complete solution because if the locale encoding is one</span><span>
</span><span id="line-165"></span><span class="hs-comment">-- which we don't have a Haskell-side decoder for, iconv might still ignore the</span><span>
</span><span id="line-166"></span><span class="hs-comment">-- lone surrogate in the input.</span><span>
</span><span id="line-167"></span><span class="hs-identifier">initLocaleEncoding</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafePerformIO</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">mkTextEncoding'</span><span> </span><span class="hs-identifier">ErrorOnCodingFailure</span><span> </span><span class="hs-identifier">Iconv.localeEncodingName</span><span>
</span><span id="line-168"></span><span class="hs-identifier">initFileSystemEncoding</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafePerformIO</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">mkTextEncoding'</span><span> </span><span class="hs-identifier">RoundtripFailure</span><span>     </span><span class="hs-identifier">Iconv.localeEncodingName</span><span>
</span><span id="line-169"></span><span class="hs-identifier">initForeignEncoding</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsafePerformIO</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">mkTextEncoding'</span><span> </span><span class="hs-identifier">IgnoreCodingFailure</span><span>  </span><span class="hs-identifier">Iconv.localeEncodingName</span><span class="hs-cpp">
#else
</span><span id="initLocaleEncoding"><span class="annot"><span class="annottext">initLocaleEncoding :: TextEncoding
</span><a href="GHC.IO.Encoding.html#initLocaleEncoding"><span class="hs-identifier hs-var hs-var">initLocaleEncoding</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.CodePage.html#localeEncoding"><span class="hs-identifier hs-var">CodePage.localeEncoding</span></a></span><span>
</span><span id="line-172"></span><span id="initFileSystemEncoding"><span class="annot"><span class="annottext">initFileSystemEncoding :: TextEncoding
</span><a href="GHC.IO.Encoding.html#initFileSystemEncoding"><span class="hs-identifier hs-var hs-var">initFileSystemEncoding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.CodePage.html#mkLocaleEncoding"><span class="hs-identifier hs-var">CodePage.mkLocaleEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#RoundtripFailure"><span class="hs-identifier hs-var">RoundtripFailure</span></a></span><span>
</span><span id="line-173"></span><span id="initForeignEncoding"><span class="annot"><span class="annottext">initForeignEncoding :: TextEncoding
</span><a href="GHC.IO.Encoding.html#initForeignEncoding"><span class="hs-identifier hs-var hs-var">initForeignEncoding</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.CodePage.html#mkLocaleEncoding"><span class="hs-identifier hs-var">CodePage.mkLocaleEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#IgnoreCodingFailure"><span class="hs-identifier hs-var">IgnoreCodingFailure</span></a></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-176"></span><span class="hs-comment">-- See Note [Windows Unicode Arguments] in rts/RtsFlags.c</span><span>
</span><span id="line-177"></span><span class="hs-comment">-- On Windows we assume hs_init argv is in utf8 encoding.</span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span class="hs-comment">-- | Internal encoding of argv</span><span>
</span><span id="line-180"></span><span class="annot"><a href="GHC.IO.Encoding.html#argvEncoding"><span class="hs-identifier hs-type">argvEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span id="argvEncoding"><span class="annot"><span class="annottext">argvEncoding :: IO TextEncoding
</span><a href="GHC.IO.Encoding.html#argvEncoding"><span class="hs-identifier hs-var hs-var">argvEncoding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.html#utf8"><span class="hs-identifier hs-var">utf8</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-identifier">argvEncoding</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">getFileSystemEncoding</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-187"></span><span class="hs-comment">-- | An encoding in which Unicode code points are translated to bytes</span><span>
</span><span id="line-188"></span><span class="hs-comment">-- by taking the code point modulo 256.  When decoding, bytes are</span><span>
</span><span id="line-189"></span><span class="hs-comment">-- translated directly into the equivalent code point.</span><span>
</span><span id="line-190"></span><span class="hs-comment">--</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- This encoding never fails in either direction.  However, encoding</span><span>
</span><span id="line-192"></span><span class="hs-comment">-- discards information, so encode followed by decode is not the</span><span>
</span><span id="line-193"></span><span class="hs-comment">-- identity.</span><span>
</span><span id="line-194"></span><span class="hs-comment">--</span><span>
</span><span id="line-195"></span><span class="hs-comment">-- @since 4.4.0.0</span><span>
</span><span id="line-196"></span><span class="annot"><a href="GHC.IO.Encoding.html#char8"><span class="hs-identifier hs-type">char8</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-197"></span><span id="char8"><span class="annot"><span class="annottext">char8 :: TextEncoding
</span><a href="GHC.IO.Encoding.html#char8"><span class="hs-identifier hs-var hs-var">char8</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="GHC.IO.Encoding.Latin1.html#latin1"><span class="hs-identifier hs-var">Latin1.latin1</span></a></span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="hs-comment">-- | Look up the named Unicode encoding.  May fail with</span><span>
</span><span id="line-200"></span><span class="hs-comment">--</span><span>
</span><span id="line-201"></span><span class="hs-comment">--  * 'System.IO.Error.isDoesNotExistError' if the encoding is unknown</span><span>
</span><span id="line-202"></span><span class="hs-comment">--</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- The set of known encodings is system-dependent, but includes at least:</span><span>
</span><span id="line-204"></span><span class="hs-comment">--</span><span>
</span><span id="line-205"></span><span class="hs-comment">--  * @UTF-8@</span><span>
</span><span id="line-206"></span><span class="hs-comment">--</span><span>
</span><span id="line-207"></span><span class="hs-comment">--  * @UTF-16@, @UTF-16BE@, @UTF-16LE@</span><span>
</span><span id="line-208"></span><span class="hs-comment">--</span><span>
</span><span id="line-209"></span><span class="hs-comment">--  * @UTF-32@, @UTF-32BE@, @UTF-32LE@</span><span>
</span><span id="line-210"></span><span class="hs-comment">--</span><span>
</span><span id="line-211"></span><span class="hs-comment">-- There is additional notation (borrowed from GNU iconv) for specifying</span><span>
</span><span id="line-212"></span><span class="hs-comment">-- how illegal characters are handled:</span><span>
</span><span id="line-213"></span><span class="hs-comment">--</span><span>
</span><span id="line-214"></span><span class="hs-comment">--  * a suffix of @\/\/IGNORE@, e.g. @UTF-8\/\/IGNORE@, will cause</span><span>
</span><span id="line-215"></span><span class="hs-comment">--    all illegal sequences on input to be ignored, and on output</span><span>
</span><span id="line-216"></span><span class="hs-comment">--    will drop all code points that have no representation in the</span><span>
</span><span id="line-217"></span><span class="hs-comment">--    target encoding.</span><span>
</span><span id="line-218"></span><span class="hs-comment">--</span><span>
</span><span id="line-219"></span><span class="hs-comment">--  * a suffix of @\/\/TRANSLIT@ will choose a replacement character</span><span>
</span><span id="line-220"></span><span class="hs-comment">--    for illegal sequences or code points.</span><span>
</span><span id="line-221"></span><span class="hs-comment">--</span><span>
</span><span id="line-222"></span><span class="hs-comment">--  * a suffix of @\/\/ROUNDTRIP@ will use a PEP383-style escape mechanism</span><span>
</span><span id="line-223"></span><span class="hs-comment">--    to represent any invalid bytes in the input as Unicode codepoints (specifically,</span><span>
</span><span id="line-224"></span><span class="hs-comment">--    as lone surrogates, which are normally invalid in UTF-32).</span><span>
</span><span id="line-225"></span><span class="hs-comment">--    Upon output, these special codepoints are detected and turned back into the</span><span>
</span><span id="line-226"></span><span class="hs-comment">--    corresponding original byte.</span><span>
</span><span id="line-227"></span><span class="hs-comment">--</span><span>
</span><span id="line-228"></span><span class="hs-comment">--    In theory, this mechanism allows arbitrary data to be roundtripped via</span><span>
</span><span id="line-229"></span><span class="hs-comment">--    a 'String' with no loss of data. In practice, there are two limitations</span><span>
</span><span id="line-230"></span><span class="hs-comment">--    to be aware of:</span><span>
</span><span id="line-231"></span><span class="hs-comment">--</span><span>
</span><span id="line-232"></span><span class="hs-comment">--      1. This only stands a chance of working for an encoding which is an ASCII</span><span>
</span><span id="line-233"></span><span class="hs-comment">--         superset, as for security reasons we refuse to escape any bytes smaller</span><span>
</span><span id="line-234"></span><span class="hs-comment">--         than 128. Many encodings of interest are ASCII supersets (in particular,</span><span>
</span><span id="line-235"></span><span class="hs-comment">--         you can assume that the locale encoding is an ASCII superset) but many</span><span>
</span><span id="line-236"></span><span class="hs-comment">--         (such as UTF-16) are not.</span><span>
</span><span id="line-237"></span><span class="hs-comment">--</span><span>
</span><span id="line-238"></span><span class="hs-comment">--      2. If the underlying encoding is not itself roundtrippable, this mechanism</span><span>
</span><span id="line-239"></span><span class="hs-comment">--         can fail. Roundtrippable encodings are those which have an injective mapping</span><span>
</span><span id="line-240"></span><span class="hs-comment">--         into Unicode. Almost all encodings meet this criteria, but some do not. Notably,</span><span>
</span><span id="line-241"></span><span class="hs-comment">--         Shift-JIS (CP932) and Big5 contain several different encodings of the same</span><span>
</span><span id="line-242"></span><span class="hs-comment">--         Unicode codepoint.</span><span>
</span><span id="line-243"></span><span class="hs-comment">--</span><span>
</span><span id="line-244"></span><span class="hs-comment">-- On Windows, you can access supported code pages with the prefix</span><span>
</span><span id="line-245"></span><span class="hs-comment">-- @CP@; for example, @\&quot;CP1250\&quot;@.</span><span>
</span><span id="line-246"></span><span class="hs-comment">--</span><span>
</span><span id="line-247"></span><span class="annot"><a href="GHC.IO.Encoding.html#mkTextEncoding"><span class="hs-identifier hs-type">mkTextEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-248"></span><span id="mkTextEncoding"><span class="annot"><span class="annottext">mkTextEncoding :: String -&gt; IO TextEncoding
</span><a href="GHC.IO.Encoding.html#mkTextEncoding"><span class="hs-identifier hs-var hs-var">mkTextEncoding</span></a></span></span><span> </span><span id="local-6989586621679530861"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530861"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe CodingFailureMode
</span><a href="#local-6989586621679530860"><span class="hs-identifier hs-var">mb_coding_failure_mode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-249"></span><span>    </span><span class="annot"><span class="annottext">Maybe CodingFailureMode
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO TextEncoding
forall a. String -&gt; IO a
</span><a href="GHC.IO.Encoding.html#unknownEncodingErr"><span class="hs-identifier hs-var">unknownEncodingErr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530861"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-250"></span><span>    </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679530858"><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530858"><span class="hs-identifier hs-var">cfm</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; String -&gt; IO TextEncoding
</span><a href="GHC.IO.Encoding.html#mkTextEncoding%27"><span class="hs-identifier hs-var">mkTextEncoding'</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530858"><span class="hs-identifier hs-var">cfm</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530856"><span class="hs-identifier hs-var">enc</span></a></span><span>
</span><span id="line-251"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-252"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679530856"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530856"><span class="hs-identifier hs-var">enc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679530854"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530854"><span class="hs-identifier hs-var">suffix</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; (String, String)
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="GHC.List.html#span"><span class="hs-identifier hs-var">span</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'/'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530861"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-253"></span><span>    </span><span id="local-6989586621679530860"><span class="annot"><span class="annottext">mb_coding_failure_mode :: Maybe CodingFailureMode
</span><a href="#local-6989586621679530860"><span class="hs-identifier hs-var hs-var">mb_coding_failure_mode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530854"><span class="hs-identifier hs-var">suffix</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-254"></span><span>        </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; Maybe CodingFailureMode
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#ErrorOnCodingFailure"><span class="hs-identifier hs-var">ErrorOnCodingFailure</span></a></span><span>
</span><span id="line-255"></span><span>        </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;//IGNORE&quot;</span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; Maybe CodingFailureMode
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#IgnoreCodingFailure"><span class="hs-identifier hs-var">IgnoreCodingFailure</span></a></span><span>
</span><span id="line-256"></span><span>        </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;//TRANSLIT&quot;</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; Maybe CodingFailureMode
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#TransliterateCodingFailure"><span class="hs-identifier hs-var">TransliterateCodingFailure</span></a></span><span>
</span><span id="line-257"></span><span>        </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;//ROUNDTRIP&quot;</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; Maybe CodingFailureMode
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#RoundtripFailure"><span class="hs-identifier hs-var">RoundtripFailure</span></a></span><span>
</span><span id="line-258"></span><span>        </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe CodingFailureMode
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-259"></span><span>
</span><span id="line-260"></span><span class="annot"><a href="GHC.IO.Encoding.html#mkTextEncoding%27"><span class="hs-identifier hs-type">mkTextEncoding'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#CodingFailureMode"><span class="hs-identifier hs-type">CodingFailureMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span>
</span><span id="line-261"></span><span id="mkTextEncoding%27"><span class="annot"><span class="annottext">mkTextEncoding' :: CodingFailureMode -&gt; String -&gt; IO TextEncoding
</span><a href="GHC.IO.Encoding.html#mkTextEncoding%27"><span class="hs-identifier hs-var hs-var">mkTextEncoding'</span></a></span></span><span> </span><span id="local-6989586621679530849"><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span></span><span> </span><span id="local-6989586621679530848"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530848"><span class="hs-identifier hs-var">enc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-262"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Char -&gt; Char
</span><a href="GHC.Unicode.html#toUpper"><span class="hs-identifier hs-var">toUpper</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679530847"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679530847"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679530847"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530848"><span class="hs-identifier hs-var">enc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679530847"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'-'</span></span><span class="hs-special">]</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-263"></span><span>  </span><span class="hs-comment">-- UTF-8 and friends we can handle ourselves</span><span>
</span><span id="line-264"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UTF8&quot;</span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO TextEncoding)
-&gt; TextEncoding -&gt; IO TextEncoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.UTF8.html#mkUTF8"><span class="hs-identifier hs-var">UTF8.mkUTF8</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span>
</span><span id="line-265"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UTF16&quot;</span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO TextEncoding)
-&gt; TextEncoding -&gt; IO TextEncoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.UTF16.html#mkUTF16"><span class="hs-identifier hs-var">UTF16.mkUTF16</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span>
</span><span id="line-266"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UTF16LE&quot;</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO TextEncoding)
-&gt; TextEncoding -&gt; IO TextEncoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.UTF16.html#mkUTF16le"><span class="hs-identifier hs-var">UTF16.mkUTF16le</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span>
</span><span id="line-267"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UTF16BE&quot;</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO TextEncoding)
-&gt; TextEncoding -&gt; IO TextEncoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.UTF16.html#mkUTF16be"><span class="hs-identifier hs-var">UTF16.mkUTF16be</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span>
</span><span id="line-268"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UTF32&quot;</span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO TextEncoding)
-&gt; TextEncoding -&gt; IO TextEncoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.UTF32.html#mkUTF32"><span class="hs-identifier hs-var">UTF32.mkUTF32</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span>
</span><span id="line-269"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UTF32LE&quot;</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO TextEncoding)
-&gt; TextEncoding -&gt; IO TextEncoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.UTF32.html#mkUTF32le"><span class="hs-identifier hs-var">UTF32.mkUTF32le</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span>
</span><span id="line-270"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UTF32BE&quot;</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO TextEncoding)
-&gt; TextEncoding -&gt; IO TextEncoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.UTF32.html#mkUTF32be"><span class="hs-identifier hs-var">UTF32.mkUTF32be</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span>
</span><span id="line-271"></span><span>    </span><span class="hs-comment">-- On AIX, we want to avoid iconv, because it is either</span><span>
</span><span id="line-272"></span><span>    </span><span class="hs-comment">-- a) totally broken, or b) non-reentrant, or c) actually works.</span><span>
</span><span id="line-273"></span><span>    </span><span class="hs-comment">-- Detecting b) is difficult as you'd have to trigger the reentrancy</span><span>
</span><span id="line-274"></span><span>    </span><span class="hs-comment">-- corruption.</span><span>
</span><span id="line-275"></span><span>    </span><span class="hs-comment">-- Therefore, on AIX, we handle the popular ASCII and latin1 encodings</span><span>
</span><span id="line-276"></span><span>    </span><span class="hs-comment">-- ourselves. For consistency, we do the same on other platforms.</span><span>
</span><span id="line-277"></span><span>    </span><span class="hs-comment">-- We use `mkLatin1_checked` instead of `mkLatin1`, since the latter</span><span>
</span><span id="line-278"></span><span>    </span><span class="hs-comment">-- completely ignores the CodingFailureMode (TEST=encoding005).</span><span>
</span><span id="line-279"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679530839"><span class="hs-identifier hs-var">isAscii</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.Latin1.html#mkAscii"><span class="hs-identifier hs-var">Latin1.mkAscii</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-280"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679530837"><span class="hs-identifier hs-var">isLatin1</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.Latin1.html#mkLatin1_checked"><span class="hs-identifier hs-var">Latin1.mkLatin1_checked</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span>    </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'C'</span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'P'</span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679530835"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530835"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span id="local-6989586621679530834"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621679530834"><span class="hs-identifier hs-var">cp</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ReadS Word32
forall a. Read a =&gt; ReadS a
</span><a href="Text.Read.html#reads"><span class="hs-identifier hs-var">reads</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530835"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; IO TextEncoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO TextEncoding)
-&gt; TextEncoding -&gt; IO TextEncoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; Word32 -&gt; TextEncoding
</span><a href="GHC.IO.Encoding.CodePage.html#mkCodePageEncoding"><span class="hs-identifier hs-var">CodePage.mkCodePageEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span> </span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621679530834"><span class="hs-identifier hs-var">cp</span></a></span><span>
</span><span id="line-283"></span><span>    </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO TextEncoding
forall a. String -&gt; IO a
</span><a href="GHC.IO.Encoding.html#unknownEncodingErr"><span class="hs-identifier hs-var">unknownEncodingErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530848"><span class="hs-identifier hs-var">enc</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; String
</span><a href="GHC.IO.Encoding.Failure.html#codingFailureModeSuffix"><span class="hs-identifier hs-var">codingFailureModeSuffix</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679530849"><span class="hs-identifier hs-var">cfm</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span>    </span><span class="hs-comment">-- Otherwise, handle other encoding needs via iconv.</span><span>
</span><span id="line-286"></span><span>
</span><span id="line-287"></span><span>    </span><span class="hs-comment">-- Unfortunately there is no good way to determine whether iconv is actually</span><span>
</span><span id="line-288"></span><span>    </span><span class="hs-comment">-- functional without telling it to do something.</span><span>
</span><span id="line-289"></span><span>    </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">res</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">Iconv.mkIconvEncoding</span><span> </span><span class="hs-identifier">cfm</span><span> </span><span class="hs-identifier">enc</span><span>
</span><span id="line-290"></span><span>            </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">res</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-291"></span><span>              </span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">e</span><span>
</span><span id="line-292"></span><span>              </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">unknownEncodingErr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">enc</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">codingFailureModeSuffix</span><span> </span><span class="hs-identifier">cfm</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-295"></span><span>    </span><span id="local-6989586621679530839"><span class="annot"><span class="annottext">isAscii :: Bool
</span><a href="#local-6989586621679530839"><span class="hs-identifier hs-var hs-var">isAscii</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530848"><span class="hs-identifier hs-var">enc</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; Bool
forall a. Eq a =&gt; a -&gt; [a] -&gt; Bool
</span><a href="GHC.List.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679530827"><span class="hs-identifier hs-var">asciiEncNames</span></a></span><span>
</span><span id="line-296"></span><span>    </span><span id="local-6989586621679530837"><span class="annot"><span class="annottext">isLatin1 :: Bool
</span><a href="#local-6989586621679530837"><span class="hs-identifier hs-var hs-var">isLatin1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530848"><span class="hs-identifier hs-var">enc</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; Bool
forall a. Eq a =&gt; a -&gt; [a] -&gt; Bool
</span><a href="GHC.List.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679530824"><span class="hs-identifier hs-var">latin1EncNames</span></a></span><span>
</span><span id="line-297"></span><span>    </span><span id="local-6989586621679530827"><span class="annot"><span class="annottext">asciiEncNames :: [String]
</span><a href="#local-6989586621679530827"><span class="hs-identifier hs-var hs-var">asciiEncNames</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- ASCII aliases specified by RFC 1345 and RFC 3808.</span><span>
</span><span id="line-298"></span><span>      </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ANSI_X3.4-1968&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;iso-ir-6&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ANSI_X3.4-1986&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ISO_646.irv:1991&quot;</span></span><span>
</span><span id="line-299"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;US-ASCII&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;us&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;IBM367&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cp367&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;csASCII&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ASCII&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ISO646-US&quot;</span></span><span>
</span><span id="line-300"></span><span>      </span><span class="hs-special">]</span><span>
</span><span id="line-301"></span><span>    </span><span id="local-6989586621679530824"><span class="annot"><span class="annottext">latin1EncNames :: [String]
</span><a href="#local-6989586621679530824"><span class="hs-identifier hs-var hs-var">latin1EncNames</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- latin1 aliases specified by RFC 1345 and RFC 3808.</span><span>
</span><span id="line-302"></span><span>      </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ISO_8859-1:1987&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;iso-ir-100&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ISO_8859-1&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ISO-8859-1&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;latin1&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-303"></span><span>        </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;l1&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;IBM819&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;CP819&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;csISOLatin1&quot;</span></span><span>
</span><span id="line-304"></span><span>      </span><span class="hs-special">]</span><span>
</span><span id="line-305"></span><span>
</span><span id="line-306"></span><span>
</span><span id="line-307"></span><span class="annot"><a href="GHC.IO.Encoding.html#latin1_encode"><span class="hs-identifier hs-type">latin1_encode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#CharBuffer"><span class="hs-identifier hs-type">CharBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Buffer.html#CharBuffer"><span class="hs-identifier hs-type">CharBuffer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-308"></span><span id="latin1_encode"><span class="annot"><span class="annottext">latin1_encode :: CharBuffer -&gt; Buffer Word8 -&gt; IO (CharBuffer, Buffer Word8)
</span><a href="GHC.IO.Encoding.html#latin1_encode"><span class="hs-identifier hs-var hs-var">latin1_encode</span></a></span></span><span> </span><span id="local-6989586621679530823"><span class="annot"><span class="annottext">CharBuffer
</span><a href="#local-6989586621679530823"><span class="hs-identifier hs-var">input</span></a></span></span><span> </span><span id="local-6989586621679530822"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679530822"><span class="hs-identifier hs-var">output</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CodingProgress, CharBuffer, Buffer Word8)
 -&gt; (CharBuffer, Buffer Word8))
-&gt; IO (CodingProgress, CharBuffer, Buffer Word8)
-&gt; IO (CharBuffer, Buffer Word8)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679530821"><span class="annot"><span class="annottext">CodingProgress
</span><a href="#local-6989586621679530821"><span class="hs-identifier hs-var">_why</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679530820"><span class="annot"><span class="annottext">CharBuffer
</span><a href="#local-6989586621679530820"><span class="hs-identifier hs-var">input'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679530819"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679530819"><span class="hs-identifier hs-var">output'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CharBuffer
</span><a href="#local-6989586621679530820"><span class="hs-identifier hs-var">input'</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679530819"><span class="hs-identifier hs-var">output'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO (CodingProgress, CharBuffer, Buffer Word8)
 -&gt; IO (CharBuffer, Buffer Word8))
-&gt; IO (CodingProgress, CharBuffer, Buffer Word8)
-&gt; IO (CharBuffer, Buffer Word8)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">EncodeBuffer
</span><a href="GHC.IO.Encoding.Latin1.html#latin1_encode"><span class="hs-identifier hs-var">Latin1.latin1_encode</span></a></span><span> </span><span class="annot"><span class="annottext">CharBuffer
</span><a href="#local-6989586621679530823"><span class="hs-identifier hs-var">input</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679530822"><span class="hs-identifier hs-var">output</span></a></span><span> </span><span class="hs-comment">-- unchecked, used for char8</span><span>
</span><span id="line-309"></span><span class="hs-comment">--latin1_encode = unsafePerformIO $ do mkTextEncoder Iconv.latin1 &gt;&gt;= return.encode</span><span>
</span><span id="line-310"></span><span>
</span><span id="line-311"></span><span class="annot"><a href="GHC.IO.Encoding.html#latin1_decode"><span class="hs-identifier hs-type">latin1_decode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#CharBuffer"><span class="hs-identifier hs-type">CharBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#CharBuffer"><span class="hs-identifier hs-type">CharBuffer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span id="latin1_decode"><span class="annot"><span class="annottext">latin1_decode :: Buffer Word8 -&gt; CharBuffer -&gt; IO (Buffer Word8, CharBuffer)
</span><a href="GHC.IO.Encoding.html#latin1_decode"><span class="hs-identifier hs-var hs-var">latin1_decode</span></a></span></span><span> </span><span id="local-6989586621679530817"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679530817"><span class="hs-identifier hs-var">input</span></a></span></span><span> </span><span id="local-6989586621679530816"><span class="annot"><span class="annottext">CharBuffer
</span><a href="#local-6989586621679530816"><span class="hs-identifier hs-var">output</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CodingProgress, Buffer Word8, CharBuffer)
 -&gt; (Buffer Word8, CharBuffer))
-&gt; IO (CodingProgress, Buffer Word8, CharBuffer)
-&gt; IO (Buffer Word8, CharBuffer)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679530815"><span class="annot"><span class="annottext">CodingProgress
</span><a href="#local-6989586621679530815"><span class="hs-identifier hs-var">_why</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679530814"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679530814"><span class="hs-identifier hs-var">input'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679530813"><span class="annot"><span class="annottext">CharBuffer
</span><a href="#local-6989586621679530813"><span class="hs-identifier hs-var">output'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679530814"><span class="hs-identifier hs-var">input'</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CharBuffer
</span><a href="#local-6989586621679530813"><span class="hs-identifier hs-var">output'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO (CodingProgress, Buffer Word8, CharBuffer)
 -&gt; IO (Buffer Word8, CharBuffer))
-&gt; IO (CodingProgress, Buffer Word8, CharBuffer)
-&gt; IO (Buffer Word8, CharBuffer)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DecodeBuffer
</span><a href="GHC.IO.Encoding.Latin1.html#latin1_decode"><span class="hs-identifier hs-var">Latin1.latin1_decode</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679530817"><span class="hs-identifier hs-var">input</span></a></span><span> </span><span class="annot"><span class="annottext">CharBuffer
</span><a href="#local-6989586621679530816"><span class="hs-identifier hs-var">output</span></a></span><span>
</span><span id="line-313"></span><span class="hs-comment">--latin1_decode = unsafePerformIO $ do mkTextDecoder Iconv.latin1 &gt;&gt;= return.encode</span><span>
</span><span id="line-314"></span><span>
</span><span id="line-315"></span><span id="local-6989586621679530954"><span class="annot"><a href="GHC.IO.Encoding.html#unknownEncodingErr"><span class="hs-identifier hs-type">unknownEncodingErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679530954"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-316"></span><span id="unknownEncodingErr"><span class="annot"><span class="annottext">unknownEncodingErr :: forall a. String -&gt; IO a
</span><a href="GHC.IO.Encoding.html#unknownEncodingErr"><span class="hs-identifier hs-var hs-var">unknownEncodingErr</span></a></span></span><span> </span><span id="local-6989586621679530811"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530811"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO a
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
-&gt; IOErrorType
-&gt; String
-&gt; String
-&gt; Maybe CInt
-&gt; Maybe String
-&gt; IOException
</span><a href="GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-var">IOError</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="GHC.IO.Exception.html#NoSuchThing"><span class="hs-identifier hs-var">NoSuchThing</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mkTextEncoding&quot;</span></span><span>
</span><span id="line-317"></span><span>                                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;unknown encoding:&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679530811"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>  </span><span class="annot"><span class="annottext">Maybe CInt
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-318"></span></pre></body></html>